package com.ptmall.app.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.ptmall.app.R;
import com.ptmall.app.base.BaseMvpActivity;
import com.ptmall.app.bean.OrderDetilBean;
import com.ptmall.app.net.api.ApiDataRepository;
import com.ptmall.app.net.base.ApiNetResponse;
import com.ptmall.app.ui.adapter.LikeGoodAdapter;
import com.ptmall.app.ui.adapter.OrderGoodAdapter;
import com.ptmall.app.utils.TimeUtil;
import com.ptmall.app.view.NoScrollGridView;
import com.ptmall.app.view.NoScrollListView;
import com.ptmall.app.view.TitleBarView;

import java.util.HashMap;
import java.util.Map;

public class ThOrderDetilActivity extends BaseMvpActivity {

    TitleBarView titlebar;
    ApiDataRepository apiDataRepository = ApiDataRepository.getInstance();
    String id;
    ImageView paystatus_img;

    NoScrollListView goodlist;

    OrderGoodAdapter mOrderGoodAdapter;

    TextView zje,qbye,th_yy,th_price,th_js,th_time,th_no,order_status;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setView(R.layout.activity_thorderdetil);
    }

    @Override
    public void initViews() {
        zje = (TextView) findViewById(R.id.zje);
        order_status = (TextView) findViewById(R.id.order_status);
        qbye = (TextView) findViewById(R.id.qbye);
        th_yy = (TextView) findViewById(R.id.th_yy);
        th_price = (TextView) findViewById(R.id.th_price);
        th_js = (TextView) findViewById(R.id.th_js);
        th_time = (TextView) findViewById(R.id.th_time);
        th_no = (TextView) findViewById(R.id.th_no);
        paystatus_img = (ImageView) findViewById(R.id.paystatus_img);
        titlebar = (TitleBarView) findViewById(R.id.titlebar);
        goodlist = (NoScrollListView) findViewById(R.id.goodlist);
        titlebar.setOnTitleBarClickListener(new TitleBarView.TitleBarClickListener() {
            @Override
            public void leftClick() {
                finish();
            }

            @Override
            public void rightClick() {

            }
        });

    }

    @Override
    public void initEvents() {
        id = getIntent().getStringExtra("id");
        mOrderGoodAdapter = new OrderGoodAdapter(getContext(),null);
        goodlist.setAdapter(mOrderGoodAdapter);

    }

    @Override
    protected void onResume() {
        super.onResume();
        getData();
    }

    private void getData(){
        Map<String,String> map = new HashMap<>();
        map.put("orderId",id);
        apiDataRepository.getTkDetil(map, new ApiNetResponse<OrderDetilBean>(getContext()) {
            @Override
            public void onSuccess(OrderDetilBean data) {
                mOrderGoodAdapter.pushData(data.product_list);
                zje.setText("￥"+data.orders_total);
                th_yy.setText("退款原因："+data.reason);
                th_price.setText("退款金额："+data.orders_total);
                th_js.setText("申请件数："+data.product_list.size());
                th_js.setText("申请时间："+data.tuiapply_time);
                th_js.setText("退款编号："+data.order_number);
                switch (data.refund_status){
                    case "1":
                        order_status.setText("等待处理");
                        break;
                    case "2":
                        order_status.setText("已同意");
                        break;
                    case "3":
                        order_status.setText("已拒绝");
                        break;
                    case "4":
                        order_status.setText("已完成");
                        break;
                }
            }
        });
    }

}
